﻿package {
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	public class W extends Sprite {
		public var skin:Sprite = new Sprite();
		public var xywh:String;
		public function W() {
			skin.graphics.lineStyle(1, 0x999999);
			skin.graphics.beginFill(0xcccccc, 1);
			skin.graphics.drawRoundRect(0, 0, 200, 100, 5);
			skin.graphics.endFill();
			addChild(skin);
		}
		public function set lock(v:String):void {
			if (parseInt(v)) {
				removeEventListener(MouseEvent.MOUSE_DOWN, d);
				skin.removeEventListener(MouseEvent.MOUSE_DOWN, sd);
			} else {
				addEventListener(MouseEvent.MOUSE_DOWN, d);
				skin.addEventListener(MouseEvent.MOUSE_DOWN, sd);
			}
		}
		public function set display(v:String):void {
			if (parseInt(v)) {
				visible = true;
			} else {
				visible = false;
			}
		}
		public function move(tx:Number, ty:Number):void {
			x = tx;
			y = ty;
		}
		//窗口深度切换
		public function d(e:MouseEvent):void {
			var top:int = this.parent.numChildren - 1;
			parent.setChildIndex(this, top);
		}
		//拖动
		public function sd(e:MouseEvent):void {
			startDrag();
			stage.addEventListener(MouseEvent.MOUSE_MOVE, moving);
			stage.addEventListener(MouseEvent.MOUSE_UP, ed);
		}
		public function ed(e:MouseEvent):void {
			stopDrag();
			stage.removeEventListener(MouseEvent.MOUSE_MOVE, moving);
			stage.removeEventListener(MouseEvent.MOUSE_UP, ed);
		}
		//吸附
		private function moving(e:MouseEvent):void {
			//trace("moving");

		}
	}
}